<%--
  Created by IntelliJ IDEA.
  User: 左宏
  Date: 2020/10/4
  Time: 15:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%
    String path=request.getContextPath()+"/";

%>
<html>
<head>
    <title>选择班级</title>
    <link href="<%=path%>static/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="<%=path%>static/css/animate.css" rel="stylesheet">
    <link href="<%=path%>static/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="<%=path%>static/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
</head>
<body class="">
<div class="wrapper wrapper-content">
    <div class="row">
            <form id="form-date-class">
                <input hidden="hidden" name="op" value="0" />
                <div style="width: 200px">
                    选择日期：<br>
                    <input type="date"class="form-control"   id="dateInput" name="date">
                </div>
                <div style="width: 200px">
                    选择班级：
                    <div class="input-group" >
                        <input type="text" class="form-control" id="classInput" name="aClass">
                        <div class="input-group-btn">
                            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                                &nbsp;<span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu dropdown-menu-left" role="menu">
                            </ul>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">
            <div class="alert alert-warning" role="alert">请选择班级</div>
        </div>
    </div>
</div>
</body>
</html>
<!-- 全局js -->
<script src="<%=path%>static/js/jquery.min.js?v=2.1.4"></script>
<script src="<%=path%>static/js/bootstrap.min.js?v=3.3.6"></script>

<!-- 自定义js -->
<script src=<%=path%>static/js/content.js?v=1.0.0"></script>

<script src="<%=path%>static/js/plugins/suggest/bootstrap-suggest.min.js"></script>

<script>
    $(function(){
        let dateInput=$("#dateInput");
        let classInput=$("#classInput");
        dateInput.val("${dateStr}");
        classInput.val("${classStr}");
        dateInput.on("change",function(){
            if(classInput.val()==="")return;
            let form=$("#form-date-class");
            form.action="education/teaching/getTimetable";
            form.method="post";
            form.target="_self";
            form.submit();
        });
        // classInput.on("change",function(){
        //     let form=$("#form-date-class");
        //     form.action="education/teaching/getTimetable?op=0";
        //     form.method="post";
        //     form.target="_self";
        //     form.submit();
        // });
        classInput.bsSuggest({
            url: "searchKeyWord?keyI=_class&keyWord=",
            keyField: "_class",
        }).on('onDataRequestSuccess', function (e, result) {
            console.log('onDataRequestSuccess: ', result);
        }).on('onSetSelectValue', function (e, keyword) {
            console.log('onSetSelectValue: ', keyword);
            if(dateInput.val()==="")return;
            let form=$("#form-date-class");
            form.action="education/teaching/getTimetable";
            form.method="post";
            form.target="_self";
            form.submit();
        }).on('onUnsetSelectValue', function (e) {
            console.log("onUnsetSelectValue");
        });
    });
</script>